Fix branch and window dragging reference issues #2915
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes two critical issues with frame dragging behavior in the canvas:
Issues Fixed
1. Branch Switching Dragging Wrong Frames
When a user created a new branch and attempted to drag the webframe topbar, the system would drag frames from the original branch instead of the current branch. This occurred because the dragging logic relied on previously selected frames rather than ensuring the clicked frame was properly selected first.
2. Window Selection Not Updating During Drag
When a user had one window selected and tried to drag a different adjacent window, the system would continue dragging the originally selected frames instead of the clicked frame. The topbar would visually respond to the hover but the actual drag operation would move the wrong frames.
Root Cause
The problem was in two areas:
TopBar Component: The
handleMouseDown
function immediately started dragging based oneditorEngine.frames.selected
without ensuring the clicked frame was selected first.FramesManager: The
select
method was toggling frame selection state (!this.isSelected(frame.id)
) even for non-multiselect operations, which could unexpectedly deselect already-selected frames.Solution
Modified Frame Selection Logic
Updated
FramesManager.select()
to behave more intuitively:Enhanced TopBar Mouse Handling
Updated the
handleMouseDown
function to select the clicked frame before initiating drag operations when:This ensures the correct frame is always selected before determining which frames to drag.
Behavior Changes
The changes are minimal and surgical, addressing the root cause while preserving all existing functionality.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
f.hubspotusercontent40.net
node scripts/postinstall.mjs
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.